package com.just.bz_back.controller;

import com.just.bz_back.delayqueue.DelayQueue;
import com.just.bz_back.model.Type;
import com.just.bz_back.model.dto.JsonDataUtil;
import com.just.bz_back.service.RedisService;
import com.just.bz_back.model.dto.JsonData;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class TestController {


    @Resource
    private RedisService redisService;

    @Resource
    private DelayQueue delayQueue;
    @RequestMapping("/test")
    public JsonData TestExp()
    {

        return JsonData.buildSuccess();

    }


    @GetMapping("add")
    public JsonData TestExp3()
    {
        delayQueue.productionDelayMessage();
        delayQueue.consumerDelayMessage();
        return JsonData.buildSuccess();
}

    @GetMapping("/getTypeList")
    public JsonData getTypeList()
    {
        int type_id=1;
        Type type= JsonDataUtil.string2Obj((String)redisService.get("TYPE_LIST_"+type_id),Type.class);
        return JsonData.buildSuccess(type);
    }



}
